import urllib2
import json

httpget = lambda value: urllib2.urlopen(value)

class Tomato(object):
   def __init__(self, Key):
      self._key = None
      if Key:
         self._key = Key

   def Search(self, Movie = None):
      retval = None
      query = None
      if Movie:
         query = Movie

      url = "http://api.rottentomatoes.com/api/public/v1.0/movies.json?"
      if query:
         url = "%sq=%s&apikey=%s" %(url, query, self._key)
         conn = httpget(url)
         retval = json.dumps(conn.read())

      return retval
